from socket import *
import os
import subprocess
import time
from datetime import timedelta
import socket

HOST, PORT = 'localhost', 20000
# SOCK_STREAM == a TCP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#sock.setblocking(0)  # optional non-blocking

subprocess.Popen("java -jar DisMyRepo.jar test.txt", shell = True)
sock.connect((HOST, PORT))

while True:

    for i in range(1,50):
        time.sleep(3)
        msg = '#insert:source:destination' + str(i) + ':randomstuff:' + str(timedelta(seconds=1317365200)) + ':$'
	sock.send(msg)
    	reply = sock.recv(16384)  # limit reply to 16K
    sock.close()
